/*
Matt Levendusky	
Proposal title: Is Perceived Polarization a Self-Fulfilling Prophecy?


HYPOTHESES

Stated-Hyp1: "H1: Ordinary voters will tend to overestimate the actual level of 
polarization in the mass electorate"

	Test-Hyp1: Percieved polarization will be higher than actual polarization on the issue of capital gains tax.
	Test-Hyp2: Percieved polarization will be higher than actual polarization on the issue of immigration.

	Test-Hyp3: Percieved polarization will be higher than actual polarization on the issue of free trade.
	
	Test-Hyp4: Percieved polarization will be higher than actual polarization on the issue of public finance.

	
Stated-Hyp2: "H2: Press coverage suggesting the electorate is divided will 
increase perceptions of polarization in the mass electorate"

	Test-Hyp5: Percieved polarization will be greater in respondents exposed to 
	high polarization vs. control, on the issue of capital gains tax.

	Test-Hyp6: Percieved polarization will be greater in respondents exposed to 
	high polarization vs. control, on the issue of immirgation.	

	Test-Hyp7: Percieved polarization will be greater in respondents exposed to 
	high polarization vs. control, on the issue of free trade.

	Test-Hyp8: Percieved polarization will be greater in respondents exposed to 
	high polarization vs. control, on the issue of public finance.		
	
	
	Test-Hyp9: Percieved polarization will be greater in respondents exposed to 
	moderate polarization vs. control, on the issue of capital gains tax.

	Test-Hyp10: Percieved polarization will be greater in respondents exposed to 
	moderate polarization vs. control, on the issue of immirgation.		
	
	Test-Hyp11: Percieved polarization will be greater in respondents exposed to 
	moderate polarization vs. moderate polarization, on the issue of free trade.

	Test-Hyp12: Percieved polarization will be greater in respondents exposed to 
	moderate polarization vs. moderate polarization, on the issue of public finance.
	
	
Stated-Hyp3: "H3: Increases in perceptions of polarization will increase actual 
polarization in the mass public."

	Test-Hyp13: There will be a positive relationship between perception of polarization 
	and having a more extreme issue position, on the issue of capital gains tax. 
	
	Test-Hyp14: There will be a positive relationship between perception of polarization 
	and having a more extreme issue position, on the issue of immigration. 

	Test-Hyp15: There will be a positive relationship between perception of polarization 
	and having a more extreme issue position, on the issue of free trade. 
	
	Test-Hyp16: There will be a positive relationship between perception of polarization 
	and having a more extreme issue position, on the issue of public finance. 	
	
Stated-Hyp4: "H4: Increases in perceptions of polarization will increase issue 
certainty in the mass electorate."

	Test-Hyp17: There will be a positive relationship between issue certainity 
	and polarization perception, on the issue of capital gains tax. Issue certainity defined as liklihood to change.
	
	Test-Hyp18: There will be a positive relationship between issue certainity 
	and polarization perception, on the issue of immigration. Issue UNcertainity defined as liklihood to change.
	
	Test-Hyp19: There will be a positive relationship between issue certainity 
	and polarization perception, on the issue of free trade. Issue certainity defined as liklihood to change.
	
	Test-Hyp20: There will be a positive relationship between issue certainity 
	and polarization perception, on the issue of public finance. Issue UNcertainity defined as liklihood to change.	
	
	
	
	
	Test-Hyp21: There will be a positive relationship between issue certainity and polarization perception, on the issue of capital gains tax. Issue certainity defined as time taken to answer question about issue position.
	
	Test-Hyp22: There will be a positive relationship between issue certainity and polarization perception, on the issue of immigration. Issue UNcertainity defined as time taken to answer question about issue position.
	
	Test-Hyp23: There will be a positive relationship between issue certainity and polarization perception, on the issue of free trade. Issue certainity defined as time taken to answer question about issue position.
	
	Test-Hyp24: There will be a positive relationship between issue certainity and polarization perception, on the issue of public finance. Issue UNcertainity defined as time taken to answer question about issue position.	
	
Stated-Hyp4: "H5: Perceptions of polarization will increase affective polarization in the mass electorate"

	Test-Hyp25: Affective polarization will be positively related with 
	overall perception of polarization

********************************************************************************
NOTES:

- Affective polarization questions should only have been asked for the other 
party (i.e. Democrats should have been asked how they feel about child marrying 
a Republican). However, there are some respondents who answered the question 
about their own party. No respondents answered questions about both Democrats 
and Republicans. Because only a small proportion of respondents answered 
same-party questions, we are removing those from the analysis of affective 
polarization.	

- Proposal says they will test 2 issues (p. 4). They ended up testing 4 issues.

- For perceptions of polarization, there are no questions about both parties 
(each respondent answered about only one party). Perception tests cannot be 
conducted for free trade and public finance isuees.

- For stated hypothesis 3, the not sure how actual polarization is to be measured. 
We define extreme position as having very anti or very for attitudes.


- For stated hypothesis 4, issue certainity is defined in the proposal as: 
		"To measure issue certainty, we ask respondents how likely they would be 
		to change their position on an issue and how deeply held their position 
		is." + "time taken to answer question" (p. 4). 

- Discussed in meeting on 4-30-2021. Decided to test stated hypotheses 
treating actual polarization as a constant.	
*/

clear all
use "Levendusky313.dta", clear

********************************************************************************

* INDICATORS OF EXPERIMENTAL MANIPULATIONS

* portrayal of polarization

	tab XTESS124
	recode XTESS124 (1=1 "1 high polarization") (2=2 "2 moderate polarization") (3=0 "0 control"), gen(treatment)
	tab treatment 
	
***********************************	
* OUTCOME MEASURES

	// respondent party (needed to construct some of the measures; see proposal)
	tab PARTY7
	recode PARTY7 (1/3=1 "1 Republican") (4=.) (5/7=0 "0 Democrat"), gen(resp_party)
	tab resp_party
	


* perceptions of polarization

	// recode missing
	foreach var in Q7 Q8 Q11 Q12 Q15a Q15b Q16a Q16b {
		replace `var'=. if `var'==-1
		tab `var'
	}

	* capital gains tax
	gen percpol_capgainstax= abs(Q7-Q8)
	tab percpol_capgainstax
	tab Q7 Q8
	
	* immigration
	gen percpol_immigration = abs(Q11-Q12)
	tab percpol_immigration
	tab Q11 Q12
	
	* free trade
	gen percpol_freetrade = abs(Q15a-Q16a)
	tab Q15a Q16a 
	
	* public financing
	gen percpol_pubfinance = abs(Q15b-Q16b)
	tab Q15b Q16b 
	

***************************************
* issue certainty


* how likely to change
	
	// Q9. capital gains taxes? 
	replace Q9=. if Q9==-1
	clonevar change_capgainstax = Q9
	
	// Q13. deporting undocumented immigrants brought to this country illegally as children? 
	replace Q13=. if Q13==-1
	clonevar change_immigration = Q13
	
	// Q17a. free trade agreements? 
	replace Q17a=. if Q17a==-1
	clonevar change_freetrade = Q17a
	

	// Q17b. public financing? 
	replace Q17b=. if Q17b==-1
	clonevar change_pubfinance = Q17b
	
	
* policy position
	
	// Q6.	capital gains tax
	
	tab Q6, nol
	replace Q6=. if Q6==-1
	clonevar position_capgainstax= Q6
	
	// Q10. immigration
	
	tab Q10, nol
	replace Q10=. if Q10==-1
	clonevar position_immigration= Q10
	
	// Q14a. free trade
	
	tab Q14a, nol
	replace Q14a=. if Q14a==-1
	clonevar position_freetrade= Q14a		
	
	// Q14b. public financing
	
	tab Q14b, nol
	replace Q14b=. if Q14b==-1
	clonevar position_pubfinance= Q14b	
	
* 	extreme position: binary indicator of whether R selected bottom or top 2 categories
	recode position_capgainstax (1/2=1) (2/5=0) (6/7=1), gen(extreme_capgainstax)
	recode position_immigration (1/2=1) (2/5=0) (6/7=1), gen(extreme_immigration)
	recode position_freetrade (1/2=1) (2/5=0) (6/7=1), gen(extreme_freetrade)
	recode position_pubfinance (1/2=1) (2/5=0) (6/7=1), gen(extreme_pubfinance)
	
* time taken to answer questions about policy position (assumption: more time = less certainity)
	
	* capital gains tax
	clonevar time_capgainstax =Q6_t
	
	* immigration
	clonevar time_immigration=Q10_t
	
	* free trade
	clonevar time_freetrade =Q14a_t
	
	* public financing
	clonevar time_pubfinance=Q14b_t
	
* overall perception of polarization
	egen percpol_overall=rowtotal(percpol_capgainstax percpol_immigration percpol_freetrade percpol_pubfinance), missing
	tab percpol_overall
************************************************	
* affective polarization (see notes above)


	// recode missing
	foreach var in Q19a Q19b Q20a Q20b {
		replace `var'=. if `var'==-1
		tab `var'
	}
	
	*Q19a. Suppose a son or daughter of yours was getting married. How would you feel if he or she married a supporter of the Democratic Party? 
	
	*Q19b. Suppose a son or daughter of yours was getting married. How would you feel if he or she married a supporter of the Republican Party? 
	
	*Q20a. How comfortable are you having close personal friends that are Democrats? 
	
	*Q20b. How comfortable are you having close personal friends that are Republicans?
	

	* recode to missing, cases where respondent answered question about own-party
	tab Q19a resp_party	
	replace Q19a=. if resp_party==0
	
	tab Q19b resp_party	
	replace Q19b=. if resp_party==1
		
	tab Q20a resp_party	
	replace Q20a=. if resp_party==0
	
	tab Q20b resp_party	
	replace Q20b=. if resp_party==1
	
	// party difference in comfort about child's marriage 
	gen marriage = Q19a
	replace marriage=Q19b if Q19a==. // higher values indicate more comfort 
	tab marriage
	replace marriage  = 4-marriage // recoding so higher values indicate discomfort
	
	// party difference in personal friendship
	gen friends = Q20a
	replace friends=Q20b if Q20a==. // higher values indicate more comfort 

	
	gen affpolarization= marriage+friends
	tab affpolarization // higher values indicate discomfort with other party


********************************************************************************

* ANALYSIS
	

*Test-Hyp1: Percieved polarization will be higher than actual polarization on the issue of capital gains tax.

// measures of interest: position_capgainstax, resp_party, percpol_capgainstax
	ttest position_capgainstax, by(resp_party)
	local actualpolmean = abs(`r(mu_1)'-`r(mu_2)')
	di `actualpolmean'
	
	ttest percpol_capgainstax == `actualpolmean'

	// do not reject. p=0.000. Percieved polarization is > than actual.
	tess +, init(Levendusky313) ttest 
	
*Test-Hyp2: Percieved polarization will be higher than actual polarization on the issue of immigration.
	ttest position_immigration, by(resp_party)
	local actualpolmean = abs(`r(mu_1)'-`r(mu_2)')
	di `actualpolmean'

	ttest percpol_immigration == `actualpolmean'	
	// do not reject. p=0.000. Percieved polarization is > than actual.
	tess +, ttest
	
	
*Test-Hyp3: Percieved polarization will be higher than actual polarization on the issue of free trade.
	ttest position_freetrade, by(resp_party)
	local actualpolmean = abs(`r(mu_1)'-`r(mu_2)')
	di `actualpolmean'

	ttest percpol_freetrade == `actualpolmean'	
	// do not reject. p=0.000. Percieved polarization is > than actual.
	tess +, ttest
	

*Test-Hyp4: Percieved polarization will be higher than actual polarization on the issue of public finance.	
	ttest position_pubfinance, by(resp_party)
	local actualpolmean = abs(`r(mu_1)'-`r(mu_2)')
	di `actualpolmean'

	ttest percpol_pubfinance == `actualpolmean'	
	// do not reject. p=0.000. Percieved polarization is > than actual.
	tess +, ttest
	
	
	
	
*Test-Hyp5: Percieved polarization will be greater in respondents exposed to high polarization vs. control, on the issue of capital gains tax.
	reg percpol_capgainstax i.treatment if treatment!=2
	// reject. 0.649
	tess 1.treatment +, bonf(4)
	
	
*Test-Hyp6: Percieved polarization will be greater in respondents exposed to high polarization vs. control, on the issue of immirgation.	
	reg percpol_immigration i.treatment if treatment!=2
	// reject. 0.120
	tess 1.treatment +, bonf(4)
	
	
*Test-Hyp7: Percieved polarization will be greater in respondents exposed to high polarization vs. control, on the issue of free trade.
	reg percpol_freetrade i.treatment if treatment!=2
	// reject. .797
	tess 1.treatment +, bonf(4)
	
*Test-Hyp8: Percieved polarization will be greater in respondents exposed to high polarization vs. control, on the issue of public finance.		
	reg percpol_pubfinance i.treatment if treatment!=2
	// reject. .451
	tess 1.treatment +, bonf(4)	
	
	
	
	
*Test-Hyp9: Percieved polarization will be greater in respondents exposed to moderate polarization vs. control, on the issue of capital gains tax.	
	reg percpol_capgainstax i.treatment if treatment!=1
	// reject. 0.037W - effect in opposite direction
	tess 2.treatment +, bonf(4)

	
*Test-Hyp10: Percieved polarization will be greater in respondents exposed to moderate polarization vs. control, on the issue of immirgation.		
	reg percpol_immigration i.treatment if treatment!=1
	// reject. 0.085
	tess 2.treatment +, bonf(4)


*	Test-Hyp11: Percieved polarization will be greater in respondents exposed to moderate polarization vs. control, on the issue of free trade.
	reg percpol_freetrade i.treatment if treatment!=1
	// reject. .289
	tess 2.treatment +, bonf(4)



* Test-Hyp12: Percieved polarization will be greater in respondents exposed to moderate polarization vs. control, on the issue of public finance.	
	reg percpol_pubfinance i.treatment if treatment!=1
	// reject. .378
	tess 2.treatment +, bonf(4)	
	
	
	
*Test-Hyp13: There will be a positive relationship between perception of polarization and having a more extreme issue position, on the issue of capital gains tax. 
	reg extreme_capgainstax percpol_capgainstax
	// do not reject. 0.000
	tess percpol_capgainstax +, bonf(3)
	
*Test-Hyp14: There will be a positive relationship between perception of polarization and having a more extreme issue position, on the issue of immigration. 
	reg extreme_immigration percpol_immigration
	// do not reject. 0.000
	tess percpol_immigration +, bonf(3)
	
	
*Test-Hyp15: There will be a positive relationship between perception of polarization and having a more extreme issue position, on the issue of free trade. 
	reg extreme_freetrade percpol_freetrade
	// do not reject. 0.000
	tess percpol_freetrade +, bonf(3)
	
*Test-Hyp16: There will be a positive relationship between perception of polarization and having a more extreme issue position, on the issue of public finance. 
	reg extreme_pubfinance percpol_pubfinance
	// do not reject. 0.000
	tess percpol_pubfinance +, bonf(3)	
	
	
	
	
*Test-Hyp17: There will be a positive relationship between issue certainity and polarization perception, on the issue of capital gains tax. Issue certainity defined as liklihood to change.
	reg change_capgainstax percpol_capgainstax
	// do not reject. 0.000
	tess percpol_capgainstax +, bonf(3)
	
	
*Test-Hyp18: There will be a positive relationship between issue certainity and polarization perception, on the issue of immigration. Issue certainity defined as liklihood to change.
	reg change_immigration percpol_immigration
	// do not reject. 0.000
	tess percpol_immigration +, bonf(3)	

*Test-Hyp19: There will be a positive relationship between issue certainity and polarization perception, on the issue of free trade. Issue certainity defined as liklihood to change.
	reg change_freetrade percpol_freetrade
	// do not reject. 0.000
	tess percpol_freetrade +, bonf(3)	

	
*Test-Hyp20: There will be a positive relationship between issue certainity and polarization perception, on the issue of public finance. Issue certainity defined as liklihood to change.
	reg change_pubfinance percpol_pubfinance
	// do not reject. 0.000
	tess percpol_pubfinance +, bonf(3)	
	
	
	
	
*Test-Hyp21: There will be a positive relationship between issue certainity and polarization perception, on the issue of capital gains tax. Issue UNcertainity defined as time taken to answer question about issue position. 
	reg time_capgainstax percpol_capgainstax
	// reject. 0.587	
	tess percpol_capgainstax -, bonf(3)
	
	
*Test-Hyp22: There will be a positive relationship between issue certainity and polarization perception, on the issue of immigration. Issue UNcertainity defined as time taken to answer question about issue position.
	reg time_immigration percpol_immigration
	// reject. 0.385
	tess percpol_immigration -, bonf(3)	

*Test-Hyp23: There will be a positive relationship between issue certainity and polarization perception, on the issue of free trade. Issue UNcertainity defined as time taken to answer question about issue position.
	reg time_freetrade percpol_freetrade
	// reject. 0.052
	tess percpol_freetrade -, bonf(3)	

	
*Test-Hyp24: There will be a positive relationship between issue certainity and polarization perception, on the issue of public finance. Issue UNcertainity defined as time taken to answer question about issue position.
	reg time_pubfinance percpol_pubfinance
	// reject. 0.230
	tess percpol_pubfinance -, bonf(3)	
		
		
		
	
*Test-Hyp25: Affective polarization will be positively related with overall perception of polarization
	reg affpolarization percpol_overall 
	// do not reject. 0.000
	tess percpol_overall +, bonf(1)		
